﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter11.Code02.Code02.Snippet11
{
    using System.Collections;

    public class Demo
    {
        public static void Begin()
        {
            {
                Person person1 = new Person("John", 28);
                Person person2 = new Person("Ann", 23);
                if (person1.CompareTo(person2) == 0)
                {
                    Console.WriteLine("Same age");
                }
                else if (person1.CompareTo(person2) > 0)
                {
                    Console.WriteLine("person1 is Older");
                }
                else
                {
                    Console.WriteLine("person1 is Younger");
                }
                Console.ReadLine();

                if (PersonComparerName.Default.Compare(person1, person2) == 0)
                {
                    Console.WriteLine("Same Name");
                }
                else
                {
                    Console.WriteLine("Different  Name");
                }
                Console.ReadLine();
            }
            {
                string firstString = "First String";
                string secondString = "Second String";
                Console.WriteLine("Comparing '{0}' and '{1}', result: {2}", firstString, secondString, Comparer.Default.Compare(firstString, secondString));
                int firstNumber = 35;
                int secondNumber = 23;
                Console.WriteLine("Comparing '{0}' and '{1}', result: {2}", firstNumber, secondNumber, Comparer.Default.Compare(firstNumber, secondNumber));
                Console.ReadLine();
            }
        }
    }
}
